#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__
#include <iostream>
#include <string>
#include <unistd.h>
class Channel
{
public:
    Channel(int wfd, pid_t who) : _wfd(wfd), _who(who)
    {
        _name = std::to_string(wfd);
        _name += "->";
        _name += std::to_string(_who);
    }
    void Send(int num) // 管道写端发送任务码
    {
        ::write(_wfd, &num, sizeof(num));
    }
    std::string GetName()
    {
        return _name;
    }
    void Close() // 关闭管道的写端
    {
        ::close(_wfd);
    }
    pid_t Getpid()
    {
        return _who;
    }
    ~Channel()
    {
    }

private:
    int _wfd;
    pid_t _who;
    std::string _name;
};
#endif